﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IO = System.IO;
using Jage.Utils;
using System.Xml.Serialization;

namespace Jage
{

    public class Configuration
        : SaveObject<Configuration>
    {

        public Configuration()
        {
            ThemeDefinitions = new List<ThemeDefinition>();
        }

        public List<ThemeDefinition> ThemeDefinitions { get; set; }

        static private Configuration _default;
        static public Configuration Default
        {
            get
            {
                if (_default == null)
                {
                    if (IO.File.Exists(Constants.ConfigurationFilename))
                    {
                        _default = Configuration.LoadFromFile(Constants.ConfigurationFilename);
                    }
                    else
                    {
                        if (!IO.Directory.Exists(Constants.DataFolder)) IO.Directory.CreateDirectory(Constants.DataFolder);
                        _default = ConfigurationFactory.Instance.GetDefaultConfiguration();
                        Configuration.SaveToFile(Constants.ConfigurationFilename, _default);
                    }
                }
                return _default;
            }
        }

    }

    public class ThemeDefinition
    {

        [XmlAttribute()]
        public string Name { get; set; }

        [XmlAttribute()]
        public string Filename { get; set; }

    }

}
